{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
				<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">原价：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="original_price" value="" name="original_price" class="form-control" placeholder="请输入原价">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">现价：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="price" value="" name="price" class="form-control" placeholder="请输入现价">
						</div>
					</div>
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">开关：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['state'])){ $info['state'] = 1; }; ?>
							<input name="state" value="1" type="radio" {if condition="$info.state eq '1'"}checked{/if} title="开启">
							<input name="state" value="0" type="radio" {if condition="$info.state eq '0'"}checked{/if} title="关闭">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">分钟：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="minute" value="" name="minute" class="form-control" placeholder="请输入分钟">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">排序：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="sort" value="" name="sort" class="form-control" placeholder="请输入排序">
						</div>
					</div>
				<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.add()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>
layui.use(['form'],function(){});
var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {
		original_price: {
			validators: {
				regexp: {
					regexp: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
					message: ''
	 			},
	 		}
	 	},
		price: {
			validators: {
				regexp: {
					regexp: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
					message: ''
	 			},
	 		}
	 	},
		minute: {
			validators: {
				regexp: {
					regexp: /^[0-9]*$/,
					message: ''
	 			},
	 		}
	 	},
	 }
}

CodeInfoDlg.collectData = function () {
	this.set('cm_id').set('original_price').set('price').set('minute').set('sort');
};

CodeInfoDlg.add = function () {
	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }
	 var state = $("input[name = 'state']:checked").val();
	 var ajax = new $ax(Feng.ctxPath + "/Customer.Money/add", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(data.msg,1000);
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(data.msg + "！",1000);
		 }
	 })
	 ajax.set('state',state);
	 ajax.set(this.CodeInfoData);
	 ajax.start();
};


</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
